home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / oldwish / wishInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-11  |  13.4 KB  |  399 lines

  1. /*
  2.  * wishInt.h --
  3.  *
  4.  *    Internal declarations for wish display.
  5.  *
  6.  * Copyright 1987 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /a/newcmds/wish/RCS/wishInt.h,v 1.4 89/01/11 11:58:53 mlgray Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _WISHINT
  20. #define _WISHINT
  21.  
  22. #include <sys/param.h>
  23. #ifndef AllPlanes
  24. #include <X11/Xlib.h>
  25. #endif
  26. #ifndef USPosition
  27. #include <X11/Xutil.h>
  28. #endif
  29. #include "cmd.h"
  30. #include "mx.h"
  31. #include "tcl.h"
  32.  
  33. #ifndef Boolean
  34. #define Boolean    int
  35. #define FALSE    0
  36. #define TRUE    1
  37. #endif /* Boolean */
  38.  
  39.  
  40. /*
  41.  * Largest number of ASCII characters required to represent an integer.
  42.  */
  43. #define CVT_INT_BUF_SIZE 34
  44.  
  45. #define    WISH_ROW_SPACING    1    /* a pleasant amount */
  46. #define    WISH_COLUMN_SPACING    15    /* another pleasant amount */
  47. #define UNINITIALIZED        -1    /* number of elements uninitialized */
  48.  
  49. /*
  50.  * To get a control character.
  51.  */
  52. #define    ctrl(c)    (c - 'a' + 1)
  53.  
  54. /*
  55.  * To determine whether finding file system attributes for a file is necessary.
  56.  */
  57. #define WISH_ATTR_NECESSARY_P\
  58.     ((aWindow->displayInstructions & ~WISH_NAME_FIELD) != 0) || \
  59.     ((aWindow->sortingInstructions & ~WISH_ALPHA_SORT) != 0) ? TRUE : FALSE
  60.  
  61. #define WISH_CHAR_TO_WIDTH(numChars, fontPtr)\
  62.     ((numChars) * XTextWidth(fontPtr, "W", 1))
  63.  
  64. /*
  65.  * Sorting flags are a bitwise and of one of the methods
  66.  * with or without "reverse."
  67.  */
  68. /* methods */ 
  69. #define    WISH_ALPHA_SORT    0x01    /* by alphabetical order */
  70. #define    WISH_ATIME_SORT    0x02    /* by access time */
  71. #define    WISH_MTIME_SORT    0x04    /* by data modify time */
  72. #define    WISH_DTIME_SORT    0x08    /* by descriptor modify time */
  73. #define    WISH_SIZE_SORT    0x10    /* by size */
  74. /* reverse */
  75. #define    WISH_REVERSE_SORT    0x20    /* whether to show in reverse order */
  76.  
  77. /*
  78.  * Display flags show which fields should be present in the display.
  79.  */
  80. #define    WISH_NAME_FIELD    0x001    /* name of the file */
  81. #define    WISH_FULLNAME_FIELD    0x002    /* full pathname to the file */
  82. #define    WISH_ATIME_FIELD    0x004    /* access time */
  83. #define    WISH_MTIME_FIELD    0x008    /* data modify time */
  84. #define    WISH_DTIME_FIELD    0x010    /* descriptor modify time */
  85. #define    WISH_SIZE_FIELD    0x020    /* size of the file in bytes */
  86. #define    WISH_DEVICE_FIELD    0x040    /* major and minor device numbers */
  87. #define    WISH_PERM_FIELD    0x080    /* permissions, owner and group */
  88. #define    WISH_TYPE_FIELD    0x100    /* directory? link? ascii? etc.... */
  89.  
  90. #define    WISH_LEFT_BUTTON    0x01
  91. #define    WISH_MIDDLE_BUTTON    0x02
  92. #define    WISH_RIGHT_BUTTON    0x04
  93. #define    WISH_META_BUTTON    0x08
  94. #define    WISH_SHIFT_BUTTON    0x10
  95.  
  96. #define    WISH_MAX_RULE_LENGTH    (2 * 1024)    /* for now the max length
  97.                          * of a rule stored in a
  98.                          * .wish file is twice
  99.                          * the max length of a path.
  100.                          * No good reason, just easy. */
  101. /* typedefs for use below */
  102. typedef    struct WishFile    WishFile;
  103. typedef    struct WishGroup    WishGroup;
  104. typedef    struct WishColumn    WishColumn;
  105. typedef    struct WishWindow    WishWindow;
  106. typedef    struct WishSelection    WishSelection;
  107. typedef    struct WishGroupBinding    WishGroupBinding;
  108.  
  109. /*
  110.  * Stuff we need to know about particular file entries.
  111.  * This will contain more information along the lines of a struct    direct
  112.  * soon.  For now, we only keep the name.
  113.  */
  114. struct WishFile {
  115.     char    *name;        /* Name of the file */
  116.     struct stat    *attrPtr;    /* file attributes */
  117.     int        length;        /* length of name in pixels */
  118.     int        x;        /* x and y coords of file name */
  119.     int        y;
  120.     int        myColumn;    /* which column the file is in */
  121.     Boolean    selectedP;    /* is the file selected? */
  122.     Boolean    lineP;        /* is whole line selected? */
  123.     Boolean    highlightP;    /* whether or not it is highlighted */
  124.     WishGroup    *myGroupPtr;    /* ptr back to my group */
  125.     struct    WishFile    *nextPtr;    /* the next one */
  126. };
  127.  
  128. /*
  129.  * Each group has a selection rule associated with it, and the files selected
  130.  * by that rule.
  131.  */
  132. #define    COMPARISON    0
  133. #define    PROC        1
  134. struct WishGroup {
  135.     int        myColumn;        /* which column I'm in */
  136.     Window    headerWindow;        /* window for header */
  137.     int        x;            /* x and y coords of group header */
  138.     int        y;
  139.     int        width;            /* width and height of header */
  140.     int        height;
  141.     int        entry_x;        /* coords of old entry window */
  142.     int        entry_y;
  143.     int        entry_width;
  144.     WishFile    *fileList;        /* list of selected files */
  145.     int        defType;        /* type of rule, tcl proc or pattern */
  146.     char    *rule;            /* selection rule */
  147.     WishGroupBinding    *groupBindings;    /* mouse button/command bindings */
  148.     int        length;            /* length of rule or name in pixels */
  149.     char    editHeader[WISH_MAX_RULE_LENGTH];    /* for entry window */
  150.     Boolean    selectedP;        /* is the group selected? */
  151.     Boolean    highlightP;        /* whether or not it is highlighted */
  152.     struct    WishGroup    *nextPtr;    /* the next one in list */
  153. };
  154.  
  155. /*
  156.  * Per-column information.  This data structure could be extended to point to
  157.  * the first file name and group appearing in the column so that redraw
  158.  * could be done be region, perhaps just columns.  Things seem fast enough
  159.  * for now, though, so I won't bother.
  160.  */
  161. struct WishColumn {
  162.     int        x;        /* x coordinate of left side of column */
  163. };
  164.  
  165. /*
  166.  * For each browser instance, there is a structure of this sort stored
  167.  * in the WishWindowTable.  The structure contains information about
  168.  * the window that the file system client wants to keep.
  169.  */
  170. struct WishWindow {
  171.     Window    surroundingWindow;        /* the surrounding window in
  172.                          * which the subwindows are
  173.                          * packed */
  174.     Window    titleWindow;            /* displays the full pathname
  175.                          * of the current directory and
  176.                          * is editable for people to
  177.                          * type in new desired dir */
  178.     Window    divider1Window;            /* thin window for a border
  179.                          * between title and menu */
  180.     Window    menuBar;            /* menu window under title */
  181.     Window    divider2Window;            /* thin window for a border
  182.                          * between menu and sort */
  183.     Window    sortWindow;            /* displays sorting method */
  184.     Window    divider3Window;            /* thin window for a border
  185.                          * between sort and fields */
  186.     Window    fieldsWindow;            /* window listing fields in
  187.                          * display (time, size, etc) */
  188.     Window    divider4Window;            /* thin window for a border
  189.                          * between fields and display */
  190.     Window    scrollWindow;            /* scrollbar window */
  191.     Window    divider5Window;            /* thin window for a border
  192.                          * between scrollbar and
  193.                          * display */
  194.     Window    txOutsideWindow;        /* tx window */
  195.     Window    divider6Window;            /* thin window for a border
  196.                          * between tx and display */
  197.     Window    displayWindow;            /* the display window */
  198.     int        windowHeight;            /* height of display window */
  199.     int        windowWidth;            /* width of display window */
  200.     Boolean    resizeP;            /* can we change geometry? */
  201.     Boolean    pickSizeP;            /* size window initially */
  202.     int        foreground;            /* foreground color */
  203.     int        background;            /* background color */
  204.     int        border;                /* border color */
  205.     int        selection;            /* selection color */
  206.     int        borderWidth;            /* width of surrounding border,
  207.                          * not really used, maybe... */
  208.     XFontStruct    *fontPtr;            /* font used for display */
  209.     GC        textGc;
  210.     GC        reverseGc;
  211.     int        titleForeground;
  212.     int        titleBackground;
  213.     int        titleBorder;
  214.     XFontStruct    *titleFontPtr;            /* font used for title */
  215.     int        txForeground;
  216.     int        txBackground;
  217.     int        txBorder;
  218.     int        menuForeground;
  219.     int        menuBackground;
  220.     int        menuBorder;
  221.     int        sortForeground;
  222.     int        sortBackground;
  223.     int        fieldsForeground;
  224.     int        fieldsBackground;
  225.     int        entryForeground;
  226.     int        entryBackground;
  227.     int        scrollForeground;
  228.     int        scrollBackground;
  229.     int        scrollElevator;
  230.     char    *geometry;            /* window geometry */
  231.     char    dir[MAXPATHLEN+1];    /* The current dir of the
  232.                          * display.  This is the full
  233.                          * pathname of the top node
  234.                          * in the display. */
  235.     char    editDir[MAXPATHLEN+1];    /* Contains dir
  236.                          * name too, but is meant for
  237.                          * editing in the title window.
  238.                          * By having both dir and
  239.                          * editDir, we don't lose the
  240.                          * actual dir when users type
  241.                          * in a potential new dir. */
  242.     int        displayInstructions;        /* display field flags */
  243.     int        sortingInstructions;        /* sorting flags */
  244.     int        maxNameLength;            /* strln of longest name */
  245.     int        maxEntryWidth;            /* longest entry width in chars,
  246.                          * not window units */
  247.     int        numElements;            /* total number of files */
  248.     int        numGroups;            /* number of groups */
  249.     int        numHiddenGroups;        /* number of groups hidden
  250.                          * because they are empty. */
  251.     Boolean    hideEmptyGroupsP;        /* whether or not to display
  252.                          * headers for empty groups. */
  253.     int        totalDisplayEntries;        /* total # of files + headers
  254.                          * plus spaces to display. */
  255.     int        numRows;            /* number of rows in display */
  256.     int        rowHeight;            /* height in pixels of rows */
  257.     int        firstElement;            /* first visible element */
  258.     int        lastElement;            /* last visible element */
  259.     int        columnWidth;            /* width of columns in pixels */
  260.     WishColumn    *columns;        /* dynamic array of columns */
  261.     int        usedCol;            /* index of last column in
  262.                          * display currently used */
  263.     int        maxColumns;            /* max # of columns allocated */
  264.     WishGroup    *groupList;            /* list of groups */
  265.     WishSelection    *selectionList;        /* list of selected stuff */
  266.     Cmd_Table    cmdTable;            /* window command interface */
  267.     Tcl_Interp    *interp;            /* tcl interpreter */
  268. #ifdef NOTDEF
  269.     char    *cmdString;            /* command in a cmd window */
  270. #endif NOTDEF
  271.     Boolean    dontDisplayChangesP;        /* to keep commands from
  272.                          * attempting redisplay while
  273.                          * we're building the
  274.                          * display from sourced
  275.                          * startup files. */
  276.     Boolean    notifierP;            /* prevent redisplay during
  277.                          * Sx_Notifies. */
  278. };
  279.  
  280. /*
  281.  * For keeping lists of selected stuff.
  282.  */
  283. struct WishSelection {
  284.     Boolean        fileP;        /* if false, it's a group */
  285.     Boolean        lineP;        /* if true, then the whole line */
  286.     union {
  287.     WishFile    *filePtr;
  288.     WishGroup    *groupPtr;
  289.     } selected;
  290.     struct WishSelection    *nextPtr;
  291. };
  292.  
  293. struct WishGroupBinding {
  294.     int        button;
  295.     char    *command;
  296.     struct WishGroupBinding    *nextPtr;
  297. };
  298.  
  299. /* Structure used to build command tables. */
  300. typedef    struct    {
  301.     char    *name;            /* command name */
  302.     int        (*proc)();        /* procedure to process command */
  303. } CmdInfo;
  304.  
  305.  
  306. /* externs */
  307.  
  308. extern    XContext    wishWindowContext;    /* table of window data */
  309. extern    XContext    wishGroupWindowContext;/* table of group data */
  310. extern    int        wishWindowCount;    /* reference count of windows */
  311.                             /* error reporting */
  312. extern    char        wishErrorMsg[/* (2*MAXPATHLEN + 50) */];
  313. extern    Boolean        wishDebugP;        /* whether debugging is on */
  314. extern    Boolean        wishResizeP;        /* can application resize? */
  315. extern    Boolean        wishPickSizeP;    /* can appl. pick size? */
  316. extern    Display        *wishDisplay;        /* the display */
  317. extern    Boolean        wishShowEmptyGroupsP;    /* show headers with no files */
  318. extern    int        wishRootHeight;    /* info about root window */
  319. extern    int        wishRootWidth;
  320. extern    char        *wishApplication;    /* application name */
  321. extern    char        wishCurrentDirectory[];    /* keep track of
  322.                              * current directory */
  323.  
  324. /*    Commands in manual page. */
  325. extern    int    WishQuitCmd();
  326. extern    int    WishToggleSelectionCmd();
  327. extern    int    WishToggleSelEntryCmd();
  328. extern    int    WishCloseCmd();
  329. extern    int    WishRedrawCmd();
  330. extern    int    WishSelectionCmd();
  331. extern    int    WishChangeDirCmd();
  332. extern    int    WishMenuCmd();
  333. extern    int    WishSortFilesCmd();
  334. extern    int    WishChangeFieldsCmd();
  335. extern    int    WishChangeGroupCmd();
  336. extern    int    WishDefineGroupCmd();
  337. extern    int    WishOpenCmd();
  338. extern    int    WishExecCmd();
  339. extern    int    WishBindCmd();
  340. extern    int    WishGroupBindCmd();
  341. extern    int    WishResizeCmd();
  342. extern    int    WishPatternCompareCmd();
  343.  
  344. /* Other externs. */
  345. extern    void    WishEditDir();
  346. extern    void    WishEditRule();
  347. extern    void    WishSelectDir();
  348. extern    void    WishScroll();
  349. extern    WishWindow    *WishCreate();
  350. extern    void    WishInit();
  351. extern    int    WishGatherNames();
  352. extern    int    WishGatherSingleGroup();
  353. extern    void    WishSetPositions();
  354. extern    void    WishRedraw();
  355. extern    void    WishRedrawFile();
  356. extern    void    WishGetFileFields();
  357. extern    void    WishRedrawGroup();
  358. extern    void    WishSetWindowAndRowInfo();
  359. extern    void    WishHandleDrawingEvent();
  360. extern    void    WishHandleDestructionEvent();
  361. extern    void    WishHandleMonitorUpdates();
  362. extern    void    WishMouseEvent();
  363. extern    void    WishHighlightMovement();
  364. extern    void    WishHandleEnterEvent();
  365. extern    char    *WishCanonicalDir();
  366. extern    void    WishGarbageCollect();
  367. extern    void    WishChangeSelection();
  368. extern    void    WishClearWholeSelection();
  369. extern    WishGroup    *WishMapCoordsToGroup();
  370. extern    WishFile    *WishMapCoordsToFile();
  371. extern    void    WishCmdTableInit();
  372. extern    void    WishAddGroupBinding();
  373. extern    void    WishDeleteGroupBindings();
  374. extern    char    *WishGetGroupBinding();
  375. extern    int    WishDoCmd();
  376. extern    void    WishChangeDir();
  377. extern    void    WishSourceConfig();
  378. extern    void    Cmd_BindingCreate();
  379. extern    char    *Cmd_BindingGet();
  380. extern    void    Cmd_BindingDelete();
  381. extern    Boolean    Cmd_EnumBindings();
  382. extern    int    Cmd_MapKey();
  383. extern    Cmd_Table    Cmd_TableCreate();
  384. extern    void    Cmd_TableDelete();
  385. extern    void    WishCvtToPrintable();
  386. extern    void    WishKeyProc();
  387. extern    void    WishMenuProc();
  388. extern    void    WishMenuEntryProc();
  389. extern    void    WishSetSort();
  390. extern    void    WishGetCompareProc();
  391. extern    void    WishGarbageGroup();
  392. extern    int    WishDoTclSelect();
  393. extern    void    WishDumpState();
  394.  
  395. /* should be in string.h! */
  396. extern    char    *index();
  397.  
  398. #endif _WISHINT
  399.